﻿using System;
using eCommerce.core.Helpers;
using eCommerce.db.BORespository;
using eCommerce.web.Controls.Sidebar;

namespace eCommerce.web.Pages
{
    public partial class ArticleDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var name = Utils.GetIdFromRequestString(Utils.Name, string.Empty);
                var o = CategoryBo.GetByUrl(name);
                
                if (!string.IsNullOrEmpty(o.Name))
                {
                    var category = LoadControl("~/Controls/Sidebar/Category.ascx");
                    ((Category)category).CategoryId     = o.CategoryId;
                    ((Category)category).TypeId         = o.TypeId;
                    ((Category)category).CategoryName   = o.Name;

                    if (category != null)
                        phLeft.Controls.Add(category);
                }
            }
        }
    }
}